<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title> test - Class: js.dom.DOMTemplate </title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <script appName="jsdk" debug="false" src="../../../../common/jsdk_loader.js">
  $import("js.dom.DOMTemplate");
  </script>
 </head>

 <body>
	 <script id="tmpl" type="text/html">
	   <table width="80%">
		 <tr bgcolor="#DEB887"><td>书籍名称</td><td>作者</td><td>出版社</td><td>价格</td></tr>
		 <% for(var n = 0; n < books.length; n++) {
			  var book = books[n];
			  if(n % 2 != 0) { 
		  %>
		  <tr bgcolor="#DCDCDC"><td>${book.name}</td><td>${book.author}</td><td>${book.plsh}</td><td>${book.price}</td></tr>
		 <% }else{   %>
		   <tr bgcolor="#FFFFE0"><td>${book.name}</td><td>${book.author}</td><td>${book.plsh}</td><td>${book.price}</td></tr>
		 <% } }  %>
	   </table>
	</script>
	<script language="javascript" type="text/javascript">
	var tpl=jsdk.DOMTemplate.newInstanceWithId("tmpl");
	tpl.setIsOnsiteOutput(true);
	tpl.parse({
		books:[
			{name:"hibernate实战教程", author:"李永胜", plsh:"李永胜出版社", price: "50.00"},
			{name:"ajax and jtle文档", author:"李永胜", plsh:"李永胜出版社", price: "0.00"},
			{name:"spring webflow教程", author:"李永胜", plsh:"李永胜出版社", price: "60.00"},
			{name:"dwr应用", author:"李永胜", plsh:"李永胜出版社", price: "30.00"}
		]
	});
	</script>
	<hr>
	<script id="tmpl1" type="text/html" src="template/books.tpl.htm"></script>
	<script language="javascript" type="text/javascript">
	var tpl=jsdk.DOMTemplate.newInstanceWithId("tmpl1");
	tpl.setIsOnsiteOutput(true);
	tpl.parse(jsdk.get("data/books1.json","",false,"","json"));
	</script>

 </body>
</html>
